package pl.edu.mimuw.irs.core.exception;

/**
 * @author Jakub Rauch
 * Created on: 2009-05-07
 */
public class InternalException extends RuntimeException {

	// *** Attributes

	// Required id
	private static final long serialVersionUID = -971661464060465302L;
	// Cause of this exception
	private Cause cause;
	private Object[] opts;
	
	// *** Methods
	
	public InternalException(Cause cause, Object... opts) {
		this.cause = cause;
		this.opts = opts;
	}
	
	@Override
	public String toString() {
		StringBuffer stringBuffer = new StringBuffer();
		stringBuffer.append("InternalException." + cause.toString());
		if (opts != null && opts.length > 0) {
			stringBuffer.append("[");
			for (Object opt : opts) {
				stringBuffer.append(opt.toString());
				stringBuffer.append(",");
			}
			stringBuffer.replace(stringBuffer.lastIndexOf(","), 
					stringBuffer.length(), "]");
		}
		
		return stringBuffer.toString();
	}

	// *** Enums

	public enum Cause {
		GLOBAL_REPEATED_ID,
		PETRI_NET_REPEATED_NODE_DETACH,
		PETRI_NET_NEGATIVE_TOKEN,
		PETRI_NET_NEGATIVE_WEIGHT_ARC,
		PETRI_NET_UNKNOWN_ARC_DIRECTION,
		PETRI_NET_UNKNOWN_NODE_TYPE,
		PETRI_NET_UNDEFINED_ELEMENT,
		PETRI_NET_NOT_A_WORKFLOW, 
		WORKFLOW_TOO_MANY_IN_PLACES, 
		WORKFLOW_TOO_MANY_OUT_PLACES, 
		WORKFLOW_NO_IN_PLACE, 
		WORKFLOW_OUT_PLACE, 
		WORKFLOW_FRAGMENTATION_NO_CHILDREN;
	}
}
